package com.example.yc23.demo.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.yc23.demo.mapper.MakerMapper;
import com.example.yc23.demo.pojo.Maker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.Map;
import java.util.function.Function;

/**
 * 添加影人信息的组件
 */

@Service
public class MakerService implements IService<Maker> {
    @Autowired
    private MakerMapper makerMapper;

    @Override
    public BaseMapper<Maker> getBaseMapper() {
        return makerMapper;
    }

    /**
     * 用于修改影人状态的方法，可以由1变0，表示状态异常，也可以恢复成1，表示状态正常
     * @param id    影人ID
     * @param state 将要修改的状态
     * @return  修改成功返回true，否则返回false
     */
    public boolean updateStateById(Integer id,Integer state){
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.set("state",state);
        wrapper.eq("id",id);
        return update(wrapper);
    }
    @Override
    public boolean saveBatch(Collection<Maker> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdateBatch(Collection<Maker> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean updateBatchById(Collection<Maker> entityList, int batchSize) {
        return false;
    }

    @Override
    public boolean saveOrUpdate(Maker entity) {
        if (entity.getId()==null){
            return save(entity);
        }else{
            return updateById(entity);
        }

    }

    @Override
    public Maker getOne(Wrapper<Maker> queryWrapper, boolean throwEx) {
        return null;
    }

    @Override
    public Map<String, Object> getMap(Wrapper<Maker> queryWrapper) {
        return null;
    }

    @Override
    public <V> V getObj(Wrapper<Maker> queryWrapper, Function<? super Object, V> mapper) {
        return null;
    }


    @Override
    public Class<Maker> getEntityClass() {
        return null;
    }
}
